package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.SchedulingSon;
import com.dragon.repository.entity.SchedulingSonSon;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class SchedulingSonVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "排产表id")
    private Integer schedulingId;

    @ApiModelProperty(value = "生产单id")
    private Integer produceId;

    @ApiModelProperty(value = "产品id")
    private Integer productId;

    @ApiModelProperty(value = "设备id")
    private Integer equipmentId;

    @ApiModelProperty(value = "排产数量")
    private Integer schedulingNum;

    @ApiModelProperty(value = "生产状态:1生产中2生产完成")
    private Integer type;

    @ApiModelProperty(value = "完成小时")
    private Double finishHour;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "是否拆解键")
    private Integer isDismantle;

    @ApiModelProperty(value = "拆解键list")
    private List<SchedulingSonSon> sonSonList;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static SchedulingSon convert(SchedulingSonVO vo) {
        SchedulingSon entity = new SchedulingSon();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<SchedulingSon> convertList(List<SchedulingSonVO> list) {
        List<SchedulingSon> resultList = new ArrayList<>();
        for (SchedulingSonVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
